cmake_minimum_required(VERSION 3.11)
SET(CMAKE_C_COMPILER "/usr/bin/gcc-10")
SET(CMAKE_CXX_COMPILER "/usr/bin/g++-10")

project(iFaultSim)

SET(CMAKE_CXX_STANDARD 20)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(FORT_ENABLE_TESTING OFF CACHE INTERNAL "") # Disable building tests and examples in libfort project

SET(CMAKE_CXX_FLAGS "-fPIC -mavx -mavx2")

# profiling
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
# SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")

SET(CMAKE_BUILD_TYPE "Release")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3")
# SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")

if(NOT DEFINED CMD_BUILD)
    set(SANITIZER OFF)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
endif()

set(BUILD_STATIC_LIB ON)

set(SANITIZER ON)

# if(SANITIZER)
#     ADD_COMPILE_OPTIONS("-fsanitize=address")
#     LINK_LIBRARIES("-fsanitize=address")
# endif()

include(cmake/setting.cmake)
include(cmake/third_party.cmake)
include(cmake/operation/fsim.cmake)

add_subdirectory(src/database)
add_subdirectory(src/operation)
add_subdirectory(src/third_party)
add_subdirectory(src/utility)